Skip to content

fix(core): cap session output tokens#36333

Draft
opencode-agent[bot] wants to merge 1 commit into
devfrom
context-overflow
Draft

fix(core): cap session output tokens#36333
opencode-agent[bot] wants to merge 1 commit into
devfrom
context-overflow

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

  • cap V2 provider turns at 32,000 output tokens, matching the existing runtime behavior
  • keep model capability limits intact while giving compaction and the provider an explicit request budget
  • cover models whose advertised output limit consumes their entire context window

Root cause

V2 left generation.maxTokens unset. Grok 4.5 advertises a 500,000-token context and 500,000-token output limit, so the provider defaulted the request to 500,000 output tokens. Even a fresh hi session then requested roughly 500,333 total tokens and failed immediately. Compaction also treated the full 500,000 tokens as reserved output.

Source report: https://x.com/dkfiander/status/2075682541026128183

Test plan

  • bun test test/session-runner.test.ts --filter 'caps output when the catalog output limit consumes the full context window'
  • bun test test/session-compaction.test.ts test/session-runner-model.test.ts
  • bun typecheck from packages/core

The repository-wide pre-push typecheck was attempted but the 3.2 GB host exhausted process resources (EAGAIN) and Bun crashed while Turbo ran 36 packages concurrently. The affected package typecheck passed independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant